<?php
@session_start();
    include_once '../../Model/M_Rol.php';
    include_once '../../Model/M_Usuario.php';
    include_once '../../Model/M_Perfil.php';

    include_once '../../Model/M_FormularioPorRol.php';
    $pagina = $_REQUEST['idPag'];
    $idUsuario = $_SESSION['id_usuario'];
    $fxr = new M_FormularioPorRol();
    $fxr->setidUsuario($idUsuario);
    $fxr->setId_Pagina($pagina);
    $listaPrivilegios = $fxr->searchVis_FormularioRol_Uno();
    
    $flag_modif = 0;
    
    for($i=0;$i<(count($listaPrivilegios));$i++)
    {
        if($listaPrivilegios[$i]['formulario']=='Modificar')
        {
            $flag_modif = 1;
        }
    }
    
    $rol = new M_Rol();
    $listaRol = $rol->searchRoles_All();
    $perfil = new M_Perfil();
    
?>
<!DOCTYPE html>
<html>
    <head>
        <title>PERFILES</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../css/principal.css">
        <link rel="stylesheet" type="text/css" href="../css/mantenedores.css">
        <script src="../media/js/jquery.js" type="text/javascript"></script>
        <script src="../media/js/jquery.dataTables.js" type="text/javascript"></script>
        
        <style type="text/css">
            @import "../media/css/demo_table_jui.css";
            @import "../media/themes/smoothness/jquery-ui-1.8.4.custom.css";
        </style>
        
        <style>
            *{
                font-family: arial;
                font-size: 8;
            }
        </style>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function(){
                $('#datatables').dataTable({
                    "sPaginationType":"full_numbers",
                    "aaSorting":[[0, "asc"]],
                    "bJQueryUI":true,
                    "oLanguage": {
                        "sLengthMenu": "Mostrar _MENU_ Registros",
                        "sZeroRecords": "No se encontraron registros",
                        "sInfo": "Mostrando _START_ de _TOTAL_ registros",
                        "sInfoEmpty": "Mostrando 0 de 0 registros",
                        "sInfoFiltered": "(Filtrado de _MAX_ registros totales)",
                        "sSearch": "Buscar:",
                        "oPaginate": {
                            "sFirst": "Primero", "sLast": "Último",  "sNext": "Siguiente", "sPrevious": "Anterior"
                        }
                    }
                });
            })
            
        </script>
        <script LANGUAGE="JavaScript">
            function confirmSubmit()
            {
                var agree = confirm("¿Desea realmente ELIMINAR este registro?");
                if (agree)
                    return true;
                else
                    return false;
            }
            // -->
        </script>
        <style>
            .ui-widget-header {
                border: 1px solid #aaaaaa;
                background: -webkit-gradient(linear,0 0,0 bottom,from(#fff),to(#efefef));
                background: -moz-linear-gradient(#fff,#efefef);
                background: linear-gradient(#fff,#efefef);
                color: #222222;
                font-weight: bold;
            }
            .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
                border: 1px solid #d3d3d3;
                background: -webkit-gradient(linear,0 0,0 bottom,from(#fff),to(#efefef));
                background: -moz-linear-gradient(#fff,#efefef);
                background: linear-gradient(#fff,#efefef);
                font-weight: normal;
                color: #555555;
            }
            .odd .sorting_1:hover,.even .sorting_1:hover, .odd:hover,.even:hover
            {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.odd td.sorting_1 {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.even td.sorting_1 {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.odd{
                background: #eeeeee;
                background: -moz-linear-gradient(top,  #eeeeee 0%, #eeeeee 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#eeeeee));
                background: -webkit-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: -o-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: -ms-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: linear-gradient(to bottom,  #eeeeee 0%,#eeeeee 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#eeeeee',GradientType=0 );
            }
        </style>
    </head>
    <body>
        <div id='lineatitulo'>            
            <label align="center" style="font-weight: bold;">Mantenedor de Perfiles</label>
        </div>
        <br/>         
        <div>
            <table id="datatables" class="display" style="font-size: 10px">
                <thead>
                    <tr>
                        <th>Nº</th>
                        <th>Rol</th>
                        <th>Usuario</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if(count($listaRol)>0)
                    {
                        for($i=0;$i<(count($listaRol));$i++) 
                        {
                        
                        
                        ?>
                    <tr>
                        <td ><?php echo ('<center>'.($i+1).'<center>');?></td>                                                
                        <td ><?php echo ('<center>'.$listaRol[$i]['nombre'].'<center>');?></td>
                        <td>
                            <?php
                            $perfil->setIdRol($listaRol[$i]['id_rol']);
                            $listaPerfil = $perfil->searchPerfiles_Uno();
                            for($j=0;$j<(count($listaPerfil));$j++) 
                            {
                                echo('<center>'.$listaPerfil[$j]['username'].'<center>');
                            }
                            ?>
                        </td>
                        <td>
                            <?if($flag_modif == 1){?>
                            <a href="V_Perfil_U.php?idRol=<?php echo ($listaRol[$i]['id_rol'].'&idPag='.$pagina);?>"><img src="../images/editar.gif"></a>
                            <?}?>
                        </td>
                        <?php
                        }
                    }
                    ?>
                    
                        
                </tbody>
            </table>
        </div>
    </body>
</html>
<?php

?>